from selenium import webdriver
from selenium.webdriver.common.by import By


class Addcart:
    def __init__(self,driver):
        self.driver=driver
    serche_locator=(By.ID,'q')
    bt_locator=(By.CLASS_NAME,'search_usercenter_btn')
    def serch_good(self,good):
        self.driver.find_element(*self.serche_locator).send_keys(good)
        self.driver.find_element(*self.bt_locator).click()
    clgoog_locator=(By.CLASS_NAME,'lazy-list')
    addgood_locator=(By.ID,'join_cart')
    def add_goods(self):
        self.driver.find_element(*self.clgoog_locator).click()
        self.driver.find_element(*self.addgood_locator).click()
    def cart_good_message(self):
        frame=self.driver.find_element(By.ID,'layui-layer-iframe1')
        self.driver.switch_to.frame(frame)
        result=self.driver.find_element(By.XPATH,'//span[text()="添加成功"]').text
        return result